package cn.yunbamboos.rest.service.transaction;

import org.springframework.transaction.TransactionStatus;
/**
 * 服务事务状态
 * */
public class ServiceTransactionStatus {
    /**
     * 1 开始状态
     * 2 提交状态
     * 3 回滚状态
     */
    private int status;

    private final TransactionStatus transactionStatus;

    /**
     * 服务事务状态
     *
     * @param transactionStatus 事务
     * */
    public ServiceTransactionStatus(TransactionStatus transactionStatus) {
        this.transactionStatus = transactionStatus;
    }

    public ServiceTransactionStatus begin() {
        this.status = 1;
        return this;
    }

    public ServiceTransactionStatus commit() {
        this.status = 2;
        return this;
    }

    public ServiceTransactionStatus rollback() {
        this.status = 3;
        return this;
    }

    public int getStatus() {
        return status;
    }

    public TransactionStatus getTransactionStatus() {
        return transactionStatus;
    }
}
